#include <iostream>
#include "Demo.h"
#include "Ray.h"
#include "Plane.h"
#include "Sphere.h"
#include "OutImage.h"
#include "OrthoCamera.h"
#include "PerspectiveCamera.h"
#include "../Rasterizer/DemoConsole.h"
#include "OBJParser.h"
#include "PointLight.h"

CDemo::CDemo(void)
{
}

CDemo::~CDemo(void)
{
}

void CDemo::PrintSection()
{
	std::cout << std::endl << "*****************************************";
}

void CDemo::PrintSection(int _sec)
{
	std::cout << std::endl << _sec << " *****************************************";
}

void CDemo::IntersectionResultRS(int _res, CVector& _vecOne,  CVector& _vecTwo)
{
	switch (_res)
	{
		case 0:
			std::cout << std::endl << "Brak punktow przeciecia!";
		break;

		case 1:
			std::cout << std::endl << "Promien styczny do sfery, punkt stycznosci: ";
			_vecOne.Print();
		break;

		case 2:
			std::cout << std::endl << "Promien przecina sfere.";
			std::cout << std::endl << "Punkt wejscia: ";
			_vecOne.Print();
			std::cout << std::endl << "Punkt wyjscia: ";
			_vecTwo.Print();
		break;
	}
}

void CDemo::IntersectionResultRP(int _res, CVector& _vecInt)
{
	switch (_res)
	{
		case 0:
			std::cout << std::endl << "Promien przecina plaszczyzne w punkcie: ";
			_vecInt.Print();
		break;

		case 1:
			std::cout << std::endl << "Przypadek szczegolny nr 1 - promien jest rownolegly do plaszczyzny";
		break;

		case 2:
			std::cout << std::endl << "Przypadek szczegolny nr 2 - promien znajduje sie za plaszczyzna";
		break;
	}
}

void CDemo::Start()
{
	COutImage *img = new COutImage(16, 16);
	CLightIntensity *color = new CLightIntensity(0.5f, 0.7f, 0.0f);
	img->SetPixel(0, 0, *color);

	CScene *scene = new CScene();

	// Cameras initialization
	COrthoCamera *camOrtho = new COrthoCamera(CVector(60.0f, 10.0f, -10.0f), CVector(0.0f, 0.0f, -5.0f));
	CPerspectiveCamera *camPersp = new CPerspectiveCamera(CVector(0.0f, 0.0f, -5.0f), CVector(0.0f, 0.0f, 1.0f));
	camPersp->SetScene(scene);

	// Obj parser initialization
	CObjParser *parserObj = new CObjParser();		// 3

	// Scene: adding objects
	scene->m_Objects.push_back(new CMesh(parserObj->ParseObj("sphere.obj")));
	//scene->m_Objects.push_back(new CTriangle(CVector(0.0f, 0.0f, 0.2f), CVector(1.0f, 0.0f, 0.2f), CVector(0.5f, 1.0f, 0.2f), CLightIntensity(0.0f, 1.0f, 0.0f)));
	//scene->m_Objects.push_back(new CTriangle(CVector(0.0f, 0.0f, 0.0f), CVector(1.0f, 0.0f, 0.0f), CVector(0.5f, 3.0f, 0.0f), CLightIntensity(0.0f, 0.0f, 1.0f)));

	// Scene: adding lights
	scene->m_Lights.push_back(new CPointLight(CVector(0.0f, 1.0f, 1.0f)));

	// Rendering
	camOrtho->Render();
	camPersp->Render();

	delete parserObj;
	delete img;
	delete scene;
	delete color;
	delete camOrtho;
	delete camPersp;
}

/*
void main()
{
	CDemo *demo = new CDemo();
	MASGK::CDemoConsole *rasterizerDemo = new MASGK::CDemoConsole();
	//demo->Start();					// FGK
	rasterizerDemo->Start();			// MASGK

	delete demo;
	delete rasterizerDemo;

	std::cout << std::endl << std::endl << "Press enter...";
	//std::cin.get();
	return;
}
*/
